# 算术运算符
a = 21
b = 10
c = 0

c = a / b
print("a 除以 b: ", c)

c = a % b
print('取余: ', c)

c = a // b
print('除数取整: ', c)


# 赋值运算符中的海象运算符
# 使用 ':=' 表示 n 被赋值, 省去了 n = 10 这步操作
if (n := 10) > 5:
    print(n)


# 位运算符
# 位运算符是针对二进制进行运算
a = 60  # 60 = 0011 1100
b = 13  # 13 = 0000 1101
c = 0

c = a & b  # 12 = 0000 1100
print('与: ', c)  # 都 1 则 1

c = a | b  # 61 = 0011 1101
print('或: ', c)  # 有 1 则 1

c = a ^ b  # 49 = 0011 0001
print('异或: ', c)  # 不同则 1

c = ~a  # -61 = 1100 0011
print('取反: ', c)  # 相反

c = a << 2  # 240 = 1111 0000
print('左移 2位: ', c)

c = a >> 2  # 15 = 0000 1111
print('右移 2位: ', c)

a = [1, 2, 3]
b = a[:]
print(b is a)
